{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 39,
   "outputs": [],
   "source": [
    "import httpx\n",
    "import pandas as pd"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-05T12:59:07.826792300Z",
     "start_time": "2024-02-05T12:59:07.823295400Z"
    }
   },
   "id": "5237a1aedf9aedde"
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "outputs": [],
   "source": [
    "# 使用httpx库发送请求\n",
    "url_query = \"https://kyfw.12306.cn/otn/leftTicket/queryE?leftTicketDTO.train_date=2024-02-18&leftTicketDTO.from_station=GYU&leftTicketDTO.to_station=SHH&purpose_codes=ADULT\""
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-05T12:59:07.851804900Z",
     "start_time": "2024-02-05T12:59:07.826792300Z"
    }
   },
   "id": "ff5c71a8f082c562"
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "outputs": [],
   "source": [
    "# 使用httpx库发送请求\n",
    "\n",
    "response = httpx.get(url=url_query,\n",
    "                     headers={\n",
    "                         \"Accept\": \"*/*\",\n",
    "                         \"Accept-Encoding\": \"gzip, deflate, br\",\n",
    "                         \"Accept-Language\": \"zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6\",\n",
    "                         \"Cookie\": \"_uab_collina=170713402790473560770278; JSESSIONID=ABE930B4E94350E48F5EFD1C085EE653; BIGipServerpassport=887619850.50215.0000; guidesStatus=off; highContrastMode=defaltMode; cursorStatus=off; route=6f50b51faa11b987e576cdb301e545c4; BIGipServerotn=1373176074.64545.0000; _jc_save_fromStation=%u8D63%u6986%2CGYU; _jc_save_toStation=%u4E0A%u6D77%2CSHH; _jc_save_toDate=2024-02-05; _jc_save_wfdc_flag=dc; _jc_save_fromDate=2024-02-19\",\n",
    "                         \"Cache-Control\": \"no-cache\",\n",
    "                         \"Connection\": \"keep-alive\",\n",
    "                         \"User-Agent\": \"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36\",\n",
    "                     },\n",
    "                     verify=False)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-05T12:59:07.987606200Z",
     "start_time": "2024-02-05T12:59:07.831085Z"
    }
   },
   "id": "8a2434204efc2d22"
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[\n",
      "  {\n",
      "    \"buttonTextInfo\": \"预订\",\n",
      "    \"queryLeftNewDTO\": {\n",
      "      \"train_no\": \"49000D213407\",\n",
      "      \"station_train_code\": \"D2131\",\n",
      "      \"start_station_telecode\": \"QDK\",\n",
      "      \"end_station_telecode\": \"AOH\",\n",
      "      \"from_station_telecode\": \"GYU\",\n",
      "      \"to_station_telecode\": \"AOH\",\n",
      "      \"start_time\": \"08:41\",\n",
      "      \"arrive_time\": \"12:41\",\n",
      "      \"lishi\": \"04:00\",\n",
      "      \"canWebBuy\": \"N\",\n",
      "      \"yp_info\": \"H%2F%2FC0Mo8eAmMoUMjdLc%2BycYwwW%2FSUnKNmau8iyckyDu9FoGL\",\n",
      "      \"start_train_date\": \"20240218\",\n",
      "      \"train_seat_feature\": \"3\",\n",
      "      \"location_code\": \"K2\",\n",
      "      \"from_station_no\": \"06\",\n",
      "      \"to_station_no\": \"15\",\n",
      "      \"is_support_card\": \"1\",\n",
      "      \"controlled_train_flag\": \"0\",\n",
      "      \"gg_num\": \"--\",\n",
      "      \"gr_num\": \"--\",\n",
      "      \"qt_num\": \"--\",\n",
      "      \"rw_num\": \"--\",\n",
      "      \"rz_num\": \"--\",\n",
      "      \"tz_num\": \"--\",\n",
      "      \"wz_num\": \"无\",\n",
      "      \"yb_num\": \"--\",\n",
      "      \"yw_num\": \"--\",\n",
      "      \"yz_num\": \"--\",\n",
      "      \"ze_num\": \"无\",\n",
      "      \"zy_num\": \"无\",\n",
      "      \"swz_num\": \"--\",\n",
      "      \"srrb_num\": \"--\",\n",
      "      \"yp_ex\": \"M0O0W0\",\n",
      "      \"seat_types\": \"MOO\",\n",
      "      \"exchange_train_flag\": \"0\",\n",
      "      \"houbu_train_flag\": \"1\",\n",
      "      \"houbu_seat_limit\": \"\",\n",
      "      \"yp_info_new\": \"M035200000O022100000O022103000\",\n",
      "      \"dw_flag\": \"0#0#0#0#z#0#z\",\n",
      "      \"stopcheckTime\": \"\",\n",
      "      \"country_flag\": \"CHN,CHN\",\n",
      "      \"local_arrive_time\": \"\",\n",
      "      \"local_start_time\": \"\",\n",
      "      \"bed_level_info\": \"\",\n",
      "      \"seat_discount_info\": \"M0094O0094W0094\",\n",
      "      \"sale_time\": \"202402041730\",\n",
      "      \"from_station_name\": \"赣榆\",\n",
      "      \"to_station_name\": \"上海虹桥\"\n",
      "    }\n",
      "  },\n",
      "  {\n",
      "    \"buttonTextInfo\": \"预订\",\n",
      "    \"queryLeftNewDTO\": {\n",
      "      \"train_no\": \"49000D292606\",\n",
      "      \"station_train_code\": \"D2923\",\n",
      "      \"start_station_telecode\": \"RCK\",\n",
      "      \"end_station_telecode\": \"AOH\",\n",
      "      \"from_station_telecode\": \"GYU\",\n",
      "      \"to_station_telecode\": \"AOH\",\n",
      "      \"start_time\": \"10:11\",\n",
      "      \"arrive_time\": \"14:41\",\n",
      "      \"lishi\": \"04:30\",\n",
      "      \"canWebBuy\": \"N\",\n",
      "      \"yp_info\": \"AUNItCOgY8K0PIEAjGGLim0CFw%2BPDEPH3%2FtUu%2BTg6qy1zjl9\",\n",
      "      \"start_train_date\": \"20240218\",\n",
      "      \"train_seat_feature\": \"3\",\n",
      "      \"location_code\": \"K2\",\n",
      "      \"from_station_no\": \"11\",\n",
      "      \"to_station_no\": \"23\",\n",
      "      \"is_support_card\": \"1\",\n",
      "      \"controlled_train_flag\": \"0\",\n",
      "      \"gg_num\": \"--\",\n",
      "      \"gr_num\": \"--\",\n",
      "      \"qt_num\": \"--\",\n",
      "      \"rw_num\": \"--\",\n",
      "      \"rz_num\": \"--\",\n",
      "      \"tz_num\": \"--\",\n",
      "      \"wz_num\": \"无\",\n",
      "      \"yb_num\": \"--\",\n",
      "      \"yw_num\": \"--\",\n",
      "      \"yz_num\": \"--\",\n",
      "      \"ze_num\": \"无\",\n",
      "      \"zy_num\": \"无\",\n",
      "      \"swz_num\": \"--\",\n",
      "      \"srrb_num\": \"--\",\n",
      "      \"yp_ex\": \"M0O0W0\",\n",
      "      \"seat_types\": \"MOO\",\n",
      "      \"exchange_train_flag\": \"0\",\n",
      "      \"houbu_train_flag\": \"1\",\n",
      "      \"houbu_seat_limit\": \"\",\n",
      "      \"yp_info_new\": \"M037200000O023200000O023203000\",\n",
      "      \"dw_flag\": \"0#1#0#0#z#0#z\",\n",
      "      \"stopcheckTime\": \"\",\n",
      "      \"country_flag\": \"CHN,CHN\",\n",
      "      \"local_arrive_time\": \"\",\n",
      "      \"local_start_time\": \"\",\n",
      "      \"bed_level_info\": \"\",\n",
      "      \"seat_discount_info\": \"M0094O0093W0093\",\n",
      "      \"sale_time\": \"202402041730\",\n",
      "      \"from_station_name\": \"赣榆\",\n",
      "      \"to_station_name\": \"上海虹桥\"\n",
      "    }\n",
      "  },\n",
      "  {\n",
      "    \"buttonTextInfo\": \"预订\",\n",
      "    \"queryLeftNewDTO\": {\n",
      "      \"train_no\": \"49000D213803\",\n",
      "      \"station_train_code\": \"D2135\",\n",
      "      \"start_station_telecode\": \"YAK\",\n",
      "      \"end_station_telecode\": \"AOH\",\n",
      "      \"from_station_telecode\": \"GYU\",\n",
      "      \"to_station_telecode\": \"AOH\",\n",
      "      \"start_time\": \"10:49\",\n",
      "      \"arrive_time\": \"15:10\",\n",
      "      \"lishi\": \"04:21\",\n",
      "      \"canWebBuy\": \"N\",\n",
      "      \"yp_info\": \"ofrCLN7pJuPM1iC9X5fPEHhoNuB3bWpHxfVKmUSYHvjWtdcw\",\n",
      "      \"start_train_date\": \"20240218\",\n",
      "      \"train_seat_feature\": \"3\",\n",
      "      \"location_code\": \"K2\",\n",
      "      \"from_station_no\": \"07\",\n",
      "      \"to_station_no\": \"20\",\n",
      "      \"is_support_card\": \"1\",\n",
      "      \"controlled_train_flag\": \"0\",\n",
      "      \"gg_num\": \"--\",\n",
      "      \"gr_num\": \"--\",\n",
      "      \"qt_num\": \"--\",\n",
      "      \"rw_num\": \"--\",\n",
      "      \"rz_num\": \"--\",\n",
      "      \"tz_num\": \"--\",\n",
      "      \"wz_num\": \"无\",\n",
      "      \"yb_num\": \"--\",\n",
      "      \"yw_num\": \"--\",\n",
      "      \"yz_num\": \"--\",\n",
      "      \"ze_num\": \"无\",\n",
      "      \"zy_num\": \"无\",\n",
      "      \"swz_num\": \"--\",\n",
      "      \"srrb_num\": \"--\",\n",
      "      \"yp_ex\": \"M0O0W0\",\n",
      "      \"seat_types\": \"MOO\",\n",
      "      \"exchange_train_flag\": \"0\",\n",
      "      \"houbu_train_flag\": \"1\",\n",
      "      \"houbu_seat_limit\": \"\",\n",
      "      \"yp_info_new\": \"M035200000O022000000O022003000\",\n",
      "      \"dw_flag\": \"0#0#0#0#z#0#z\",\n",
      "      \"stopcheckTime\": \"\",\n",
      "      \"country_flag\": \"CHN,CHN\",\n",
      "      \"local_arrive_time\": \"\",\n",
      "      \"local_start_time\": \"\",\n",
      "      \"bed_level_info\": \"\",\n",
      "      \"seat_discount_info\": \"M0094O0093W0093\",\n",
      "      \"sale_time\": \"202402041730\",\n",
      "      \"from_station_name\": \"赣榆\",\n",
      "      \"to_station_name\": \"上海虹桥\"\n",
      "    }\n",
      "  },\n",
      "  {\n",
      "    \"buttonTextInfo\": \"预订\",\n",
      "    \"queryLeftNewDTO\": {\n",
      "      \"train_no\": \"48000G758501\",\n",
      "      \"station_train_code\": \"G7585\",\n",
      "      \"start_station_telecode\": \"GYU\",\n",
      "      \"end_station_telecode\": \"VRH\",\n",
      "      \"from_station_telecode\": \"GYU\",\n",
      "      \"to_station_telecode\": \"AOH\",\n",
      "      \"start_time\": \"13:03\",\n",
      "      \"arrive_time\": \"17:12\",\n",
      "      \"lishi\": \"04:09\",\n",
      "      \"canWebBuy\": \"N\",\n",
      "      \"yp_info\": \"GgKj5AuCIfRgYdaAcD9KwXjSIjK3tj4p8t67WYPtpD2usCXo\",\n",
      "      \"start_train_date\": \"20240218\",\n",
      "      \"train_seat_feature\": \"3\",\n",
      "      \"location_code\": \"H2\",\n",
      "      \"from_station_no\": \"01\",\n",
      "      \"to_station_no\": \"14\",\n",
      "      \"is_support_card\": \"1\",\n",
      "      \"controlled_train_flag\": \"0\",\n",
      "      \"gg_num\": \"--\",\n",
      "      \"gr_num\": \"--\",\n",
      "      \"qt_num\": \"--\",\n",
      "      \"rw_num\": \"--\",\n",
      "      \"rz_num\": \"--\",\n",
      "      \"tz_num\": \"--\",\n",
      "      \"wz_num\": \"无\",\n",
      "      \"yb_num\": \"--\",\n",
      "      \"yw_num\": \"--\",\n",
      "      \"yz_num\": \"--\",\n",
      "      \"ze_num\": \"无\",\n",
      "      \"zy_num\": \"无\",\n",
      "      \"swz_num\": \"--\",\n",
      "      \"srrb_num\": \"--\",\n",
      "      \"yp_ex\": \"M0O0W0\",\n",
      "      \"seat_types\": \"MOO\",\n",
      "      \"exchange_train_flag\": \"0\",\n",
      "      \"houbu_train_flag\": \"1\",\n",
      "      \"houbu_seat_limit\": \"\",\n",
      "      \"yp_info_new\": \"M046300000O029000000O029003000\",\n",
      "      \"dw_flag\": \"0#0#0#0#z#0#z\",\n",
      "      \"stopcheckTime\": \"\",\n",
      "      \"country_flag\": \"CHN,CHN\",\n",
      "      \"local_arrive_time\": \"\",\n",
      "      \"local_start_time\": \"\",\n",
      "      \"bed_level_info\": \"\",\n",
      "      \"seat_discount_info\": \"\",\n",
      "      \"sale_time\": \"202402041730\",\n",
      "      \"from_station_name\": \"赣榆\",\n",
      "      \"to_station_name\": \"上海虹桥\"\n",
      "    }\n",
      "  },\n",
      "  {\n",
      "    \"buttonTextInfo\": \"预订\",\n",
      "    \"queryLeftNewDTO\": {\n",
      "      \"train_no\": \"49000D214510\",\n",
      "      \"station_train_code\": \"D2145\",\n",
      "      \"start_station_telecode\": \"QHK\",\n",
      "      \"end_station_telecode\": \"AOH\",\n",
      "      \"from_station_telecode\": \"GYU\",\n",
      "      \"to_station_telecode\": \"AOH\",\n",
      "      \"start_time\": \"15:50\",\n",
      "      \"arrive_time\": \"19:09\",\n",
      "      \"lishi\": \"03:19\",\n",
      "      \"canWebBuy\": \"N\",\n",
      "      \"yp_info\": \"8sUHtEsbPAhMECHXKAttFQyrRCRlZI9BS24GCkmRlQXfivuC\",\n",
      "      \"start_train_date\": \"20240218\",\n",
      "      \"train_seat_feature\": \"3\",\n",
      "      \"location_code\": \"K2\",\n",
      "      \"from_station_no\": \"04\",\n",
      "      \"to_station_no\": \"07\",\n",
      "      \"is_support_card\": \"1\",\n",
      "      \"controlled_train_flag\": \"0\",\n",
      "      \"gg_num\": \"--\",\n",
      "      \"gr_num\": \"--\",\n",
      "      \"qt_num\": \"--\",\n",
      "      \"rw_num\": \"--\",\n",
      "      \"rz_num\": \"--\",\n",
      "      \"tz_num\": \"--\",\n",
      "      \"wz_num\": \"无\",\n",
      "      \"yb_num\": \"--\",\n",
      "      \"yw_num\": \"--\",\n",
      "      \"yz_num\": \"--\",\n",
      "      \"ze_num\": \"无\",\n",
      "      \"zy_num\": \"无\",\n",
      "      \"swz_num\": \"--\",\n",
      "      \"srrb_num\": \"--\",\n",
      "      \"yp_ex\": \"M0O0W0\",\n",
      "      \"seat_types\": \"MOO\",\n",
      "      \"exchange_train_flag\": \"0\",\n",
      "      \"houbu_train_flag\": \"1\",\n",
      "      \"houbu_seat_limit\": \"\",\n",
      "      \"yp_info_new\": \"M037100000O023300000O023303000\",\n",
      "      \"dw_flag\": \"0#0#0#0#z#0#z\",\n",
      "      \"stopcheckTime\": \"\",\n",
      "      \"country_flag\": \"CHN,CHN\",\n",
      "      \"local_arrive_time\": \"\",\n",
      "      \"local_start_time\": \"\",\n",
      "      \"bed_level_info\": \"\",\n",
      "      \"seat_discount_info\": \"M0099O0099W0099\",\n",
      "      \"sale_time\": \"202402041730\",\n",
      "      \"from_station_name\": \"赣榆\",\n",
      "      \"to_station_name\": \"上海虹桥\"\n",
      "    }\n",
      "  },\n",
      "  {\n",
      "    \"buttonTextInfo\": \"预订\",\n",
      "    \"queryLeftNewDTO\": {\n",
      "      \"train_no\": \"49000D293004\",\n",
      "      \"station_train_code\": \"D2927\",\n",
      "      \"start_station_telecode\": \"WKK\",\n",
      "      \"end_station_telecode\": \"AOH\",\n",
      "      \"from_station_telecode\": \"GYU\",\n",
      "      \"to_station_telecode\": \"AOH\",\n",
      "      \"start_time\": \"18:22\",\n",
      "      \"arrive_time\": \"22:38\",\n",
      "      \"lishi\": \"04:16\",\n",
      "      \"canWebBuy\": \"N\",\n",
      "      \"yp_info\": \"vuxBRbDXcVnW5yBj3kX2ptQhw0lEN7UoDKij%2BjfFsKkG67C7\",\n",
      "      \"start_train_date\": \"20240218\",\n",
      "      \"train_seat_feature\": \"3\",\n",
      "      \"location_code\": \"K2\",\n",
      "      \"from_station_no\": \"09\",\n",
      "      \"to_station_no\": \"21\",\n",
      "      \"is_support_card\": \"1\",\n",
      "      \"controlled_train_flag\": \"0\",\n",
      "      \"gg_num\": \"--\",\n",
      "      \"gr_num\": \"--\",\n",
      "      \"qt_num\": \"--\",\n",
      "      \"rw_num\": \"--\",\n",
      "      \"rz_num\": \"--\",\n",
      "      \"tz_num\": \"--\",\n",
      "      \"wz_num\": \"无\",\n",
      "      \"yb_num\": \"--\",\n",
      "      \"yw_num\": \"--\",\n",
      "      \"yz_num\": \"--\",\n",
      "      \"ze_num\": \"无\",\n",
      "      \"zy_num\": \"无\",\n",
      "      \"swz_num\": \"--\",\n",
      "      \"srrb_num\": \"--\",\n",
      "      \"yp_ex\": \"M0O0W0\",\n",
      "      \"seat_types\": \"MOO\",\n",
      "      \"exchange_train_flag\": \"0\",\n",
      "      \"houbu_train_flag\": \"1\",\n",
      "      \"houbu_seat_limit\": \"\",\n",
      "      \"yp_info_new\": \"M039900000O025000000O025003000\",\n",
      "      \"dw_flag\": \"0#0#0#0#z#0#z\",\n",
      "      \"stopcheckTime\": \"\",\n",
      "      \"country_flag\": \"CHN,CHN\",\n",
      "      \"local_arrive_time\": \"\",\n",
      "      \"local_start_time\": \"\",\n",
      "      \"bed_level_info\": \"\",\n",
      "      \"seat_discount_info\": \"\",\n",
      "      \"sale_time\": \"202402041730\",\n",
      "      \"from_station_name\": \"赣榆\",\n",
      "      \"to_station_name\": \"上海虹桥\"\n",
      "    }\n",
      "  },\n",
      "  {\n",
      "    \"buttonTextInfo\": \"预订\",\n",
      "    \"queryLeftNewDTO\": {\n",
      "      \"train_no\": \"49000D215403\",\n",
      "      \"station_train_code\": \"D2151\",\n",
      "      \"start_station_telecode\": \"RCK\",\n",
      "      \"end_station_telecode\": \"AOH\",\n",
      "      \"from_station_telecode\": \"GYU\",\n",
      "      \"to_station_telecode\": \"AOH\",\n",
      "      \"start_time\": \"18:34\",\n",
      "      \"arrive_time\": \"22:32\",\n",
      "      \"lishi\": \"03:58\",\n",
      "      \"canWebBuy\": \"N\",\n",
      "      \"yp_info\": \"8sUHtEsbPAhMECHXKAttFQyrRCRlZI9BS24GCkmRlQXfivuC\",\n",
      "      \"start_train_date\": \"20240218\",\n",
      "      \"train_seat_feature\": \"3\",\n",
      "      \"location_code\": \"K2\",\n",
      "      \"from_station_no\": \"06\",\n",
      "      \"to_station_no\": \"15\",\n",
      "      \"is_support_card\": \"1\",\n",
      "      \"controlled_train_flag\": \"0\",\n",
      "      \"gg_num\": \"--\",\n",
      "      \"gr_num\": \"--\",\n",
      "      \"qt_num\": \"--\",\n",
      "      \"rw_num\": \"--\",\n",
      "      \"rz_num\": \"--\",\n",
      "      \"tz_num\": \"--\",\n",
      "      \"wz_num\": \"无\",\n",
      "      \"yb_num\": \"--\",\n",
      "      \"yw_num\": \"--\",\n",
      "      \"yz_num\": \"--\",\n",
      "      \"ze_num\": \"无\",\n",
      "      \"zy_num\": \"无\",\n",
      "      \"swz_num\": \"--\",\n",
      "      \"srrb_num\": \"--\",\n",
      "      \"yp_ex\": \"M0O0W0\",\n",
      "      \"seat_types\": \"MOO\",\n",
      "      \"exchange_train_flag\": \"0\",\n",
      "      \"houbu_train_flag\": \"1\",\n",
      "      \"houbu_seat_limit\": \"\",\n",
      "      \"yp_info_new\": \"M037100000O023300000O023303000\",\n",
      "      \"dw_flag\": \"0#0#0#0#z#0#z\",\n",
      "      \"stopcheckTime\": \"\",\n",
      "      \"country_flag\": \"CHN,CHN\",\n",
      "      \"local_arrive_time\": \"\",\n",
      "      \"local_start_time\": \"\",\n",
      "      \"bed_level_info\": \"\",\n",
      "      \"seat_discount_info\": \"M0099O0099W0099\",\n",
      "      \"sale_time\": \"202402041730\",\n",
      "      \"from_station_name\": \"赣榆\",\n",
      "      \"to_station_name\": \"上海虹桥\"\n",
      "    }\n",
      "  }\n",
      "]\n"
     ]
    }
   ],
   "source": [
    "# 打印返回值\n",
    "#使用orgjson格式化返回值, 解析成json\n",
    "import orjson\n",
    "resp_json = orjson.loads(response.text)\n",
    "db = resp_json['data']['result']\n",
    "dd = {\n",
    "    \"AOH\": \"上海虹桥\",\n",
    "    \"GYU\": \"赣榆\",\n",
    "}\n",
    "# 12306的result是一个字符串，需要自己解析\n",
    "def cM(db, dd):\n",
    "    da = []\n",
    "    for c9 in db:\n",
    "        de = {}\n",
    "        c8 = c9.split(\"|\")\n",
    "        # de['secretStr'] = c8[0]\n",
    "        de['buttonTextInfo'] = c8[1]\n",
    "        dc = {\n",
    "            'train_no': c8[2],\n",
    "            'station_train_code': c8[3],\n",
    "            'start_station_telecode': c8[4],\n",
    "            'end_station_telecode': c8[5],\n",
    "            'from_station_telecode': c8[6],\n",
    "            'to_station_telecode': c8[7],\n",
    "            'start_time': c8[8],\n",
    "            'arrive_time': c8[9],\n",
    "            'lishi': c8[10],\n",
    "            'canWebBuy': c8[11],\n",
    "            'yp_info': c8[12],\n",
    "            'start_train_date': c8[13],\n",
    "            'train_seat_feature': c8[14],\n",
    "            'location_code': c8[15],\n",
    "            'from_station_no': c8[16],\n",
    "            'to_station_no': c8[17],\n",
    "            'is_support_card': c8[18],\n",
    "            'controlled_train_flag': c8[19],\n",
    "            'gg_num': c8[20] if c8[20] else \"--\",\n",
    "            'gr_num': c8[21] if c8[21] else \"--\",\n",
    "            'qt_num': c8[22] if c8[22] else \"--\",\n",
    "            'rw_num': c8[23] if c8[23] else \"--\",\n",
    "            'rz_num': c8[24] if c8[24] else \"--\",\n",
    "            'tz_num': c8[25] if c8[25] else \"--\",\n",
    "            'wz_num': c8[26] if c8[26] else \"--\",\n",
    "            'yb_num': c8[27] if c8[27] else \"--\",\n",
    "            'yw_num': c8[28] if c8[28] else \"--\",\n",
    "            'yz_num': c8[29] if c8[29] else \"--\",\n",
    "            'ze_num': c8[30] if c8[30] else \"--\",\n",
    "            'zy_num': c8[31] if c8[31] else \"--\",\n",
    "            'swz_num': c8[32] if c8[32] else \"--\",\n",
    "            'srrb_num': c8[33] if c8[33] else \"--\",\n",
    "            'yp_ex': c8[34],\n",
    "            'seat_types': c8[35],\n",
    "            'exchange_train_flag': c8[36],\n",
    "            'houbu_train_flag': c8[37],\n",
    "            'houbu_seat_limit': c8[38],\n",
    "            'yp_info_new': c8[39],\n",
    "            'dw_flag': c8[46],\n",
    "            'stopcheckTime': c8[48],\n",
    "            'country_flag': c8[49],\n",
    "            'local_arrive_time': c8[50],\n",
    "            'local_start_time': c8[51],\n",
    "            'bed_level_info': c8[53],\n",
    "            'seat_discount_info': c8[54],\n",
    "            'sale_time': c8[55],\n",
    "            'from_station_name': dd.get(c8[6], \"\"),\n",
    "            'to_station_name': dd.get(c8[7], \"\"),\n",
    "        }\n",
    "        de['queryLeftNewDTO'] = dc\n",
    "        da.append(de)\n",
    "    return da\n",
    "parse_ret = cM(db, dd)\n",
    "# 使用orgjson格式化返回值, 解析成json\n",
    "print(orjson.dumps(parse_ret, option=orjson.OPT_INDENT_2).decode('utf-8'))"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-05T12:59:08.016434400Z",
     "start_time": "2024-02-05T12:59:07.988202700Z"
    }
   },
   "id": "804046dd0d49bb63"
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-05T12:59:08.016434400Z",
     "start_time": "2024-02-05T12:59:07.997932Z"
    }
   },
   "id": "de88964d50170c63"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
